<template>
  <div class="t-quv">
    <div class="t-quv-head">
      <h5>快捷导航</h5>
      <el-link>更多</el-link>
    </div>
    <div v-if="navList && navList.length > 0" class="t-quv-content">
      <div v-for="(item, index) in navList" :key="index" @click="goMenu(item)" :class="['t-quv-content-card', index >= navList.length - ((navList.length % 3) || 3) ? 'bottom-border-none' : '']">
        <svg-icon class="t-quv-content-card-icon" :icon-class="item.quickIcon" />
        <span>{{ item.quickLabel }}</span>
      </div>
    </div>
    <div v-else class="t-quv-content" style="display: flex; align-items: center; justify-content: center">
      <el-empty description="还未设置快捷菜单" />
    </div>
  </div>
</template>

<script setup name="QuickNav">
import {listMineQuick} from "@/api/system/sysUserQuick";
import {useRouter} from "vue-router";

const router = useRouter();

const navList = ref([]);

const getMineQuickList = () => {
  listMineQuick().then(res => {
    if (res.code === 200) {
      navList.value = res.data;
    }
  })
}

const goMenu = (row) => {
  router.push({
    path: row.quickPath
  })
}

getMineQuickList();
</script>

<style scoped lang="scss">
.t-quv {
  background-color: #ffffff;
  border-radius: 8px;

  &-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);

    > h5 {
      margin: 0;
      font-size: 16px;
      color: rgba(0, 0, 0, 0.8);

    }
  }

  &-content {
    display: flex;
    flex-flow: wrap;

    &-card {
      padding: 20px;
      width: 33.33%;
      border-right: 1px solid rgba(0, 0, 0, 0.05);
      border-bottom: 1px solid rgba(0, 0, 0, 0.05);
      cursor: pointer;
      user-select: none;
      display: flex;
      align-items: center;
      flex-flow: column;
      justify-content: center;

      &-icon {
        width: 20px;
        height: 20px;
        color: rgba(0, 0, 0, 0.7);
      }

      > span {
        margin-top: 10px;
        font-size: 14px;
        color: rgba(0, 0, 0, 0.7);
      }

    }

    &-card:nth-child(3n) {
      border-right: none;
    }
  }
}
</style>

